1 *************************************************
7 *************************************************
11 * The complete and unmodified archive, as *
12 * provided by Tomi Blinnikka, may be freely *
13 * redistributed via any means which preserves *
14 * its copyrights. The archive may not be sold *
17 * Permission granted to be distributed with the *
18 * AHI user/development software. *
20 *************************************************
24 * GETAUDIOID IS PROVIDED "AS-IS" AND SUBJECT TO *
25 * CHANGE; NO WARRANTIES ARE MADE. ALL USE IS *
26 * AT YOUR OWN RISK. NO LIABILITY OR *
27 * RESPONSIBILITY IS ASSUMED. *
29 *************************************************
33 * A program to display AHI AudioID requester *
34 * and print selected ID in hex and decimal. *
36 * Requires Kickstart 2.04+, ahi.device 1+. *
38 *************************************************
42 * Version 0.01 29.04.1996 *
43 * -0.99รถ 29.04.1996 *
48 * Version 1.00 30.04.1996 *
50 * Works from CLI/Shell & Workbench. *
52 * Added TITLE, POSITIVE, NEGATIVE, LFORMAT & *
53 * PUBSCREEN options. *
55 * Added Locale support. *
58 * Version 1.01 01.05.1996 *
60 * Doesn't set an initial AudioID anymore, *
61 * since Martin tells my shouldn't make *
62 * assumptions about direct IDs. *
64 * Recompiled with tags names from AHI beta 2. *
66 * If no mode was selected then returns -5. *
72 *************************************************
74 INCLUDE "dos/dosextens.i"
75 INCLUDE "devices/ahi.i"
76 INCLUDE "libraries/locale.i"
77 INCLUDE "workbench/startup.i"
79 INCLUDE "JMPLibs.i" ;Macros to open/close/call libs
80 INCLUDE "lvo/ahi_lib.i" ;ahi.device offsets
84 INCLUDE "XREF:2.0.xref"
85 INCLUDE "XREF:exec.xref"
86 INCLUDE "XREF:dos.xref"
87 INCLUDE "XREF:icon.xref"
92 AHI_DEFMIXFREQ: EQU 30058 ;Sounds a lot better than 11kHz...
95 dc.b "1.01 (01.05.96)"
99 ;Use these and leave a few hundred include lines out
104 do_ToolTypes: EQU $36
109 START: push all ;Save registers
111 sub.l a1,a1 ;Find our task
117 lea.l pr_MsgPort(a4),a0
119 lea.l pr_MsgPort(a4),a0
120 flib Exec,GetMsg ;Get WB message
123 OpenDos: openlib Dos,NoDos ;Keep at beginning
125 moveq.l #0,d1 ;Go to root
127 move.l d0,OrigLock ;This is where we came from
132 openlib Locale,NoLocale
135 jlib Locale,OpenLocale
138 sub.l a0,a0 ;No locale, use default
139 lea.l CatalogName1,a1
141 jlib Locale,OpenCatalogA ;Open our catalog for this language
146 ;Here we set the text strings using locale support
149 lea.l CatStrings,a3 ;Def. String in A1
151 LocaleLoop: move.l d7,d0 ;StringNum in D0
152 move.l GAICatalog,a0 ;Catalog in A0
153 move.l (a3),a1 ;Default string in A1
154 jlib Locale,GetCatalogStr
160 cmp.l #CatStrAmount,d7
164 ;Fix strings that aren't move.l'd
166 NoLocale: move.l STRAHIReqTitle1,OptTitle
167 move.l STRPositiveText2,OptPositive
168 move.l STRNegativeText2,OptNegative
172 beq CLIStart ;Skip WB stuff if from CLI
175 ;Open CON: window where we print errors and the result.
178 move.l #MODE_OLDFILE,d2
182 move.l CONFile,_stdout
187 move.l sm_ArgList(a0),a1
188 move.l wa_Lock(a1),d1
189 jlib Dos,CurrentDir ;Change to the directory where our icon is
192 ;The icon we open here can't be free'd until all the data from them has
193 ;been dealt with, i.e. until the progrma ends.
196 move.l sm_ArgList(a0),a1
197 move.l wa_Name(a1),a0
198 jlib Icon,GetDiskObject ;Get icon
202 DoToolType1: move.l d0,a4
203 move.l do_ToolTypes(a4),a0
204 lea.l DECIMALText1,a1
205 flib Icon,FindToolType
208 move.l #1,OptDecimal ;This user wants decimal ID
210 DoToolType2: move.l do_ToolTypes(a4),a0
212 flib Icon,FindToolType
215 move.l d0,OptTitle ;This title, please
217 DoToolType3: move.l do_ToolTypes(a4),a0
218 lea.l POSITIVEText1,a1
219 flib Icon,FindToolType
222 move.l d0,OptPositive ;This positive gad text
224 DoToolType4: move.l do_ToolTypes(a4),a0
225 lea.l NEGATIVEText1,a1
226 flib Icon,FindToolType
229 move.l d0,OptNegative ;This negative gad text
231 DoToolType5: move.l do_ToolTypes(a4),a0
232 lea.l LFORMATText1,a1
233 flib Icon,FindToolType
236 move.l d0,OptLFormat ;Format with this
238 DoToolType6: move.l do_ToolTypes(a4),a0
239 lea.l PUBSCREENText1,a1
240 flib Icon,FindToolType
243 move.l d0,OptPubScreen ;Open on this public screen
245 bra MainStart ;Skip CLI stuff
248 CLIStart: jlib Dos,Output
251 move.l #CLTemplate1,d1
254 flib Dos,ReadArgs ;Read options from CLI
263 beq NoAHI ;Open failed
266 ;Let's set all the options correctly
268 move.l (OptTitle),ReqTitle
269 move.l (OptPositive),ReqPos
270 move.l (OptNegative),ReqNeg
271 move.l (OptPubScreen),ReqPubScr
274 ;Here we go and check that the user specified formatting string doesn't
275 ;contain more than two '%ld' strings.
278 beq OpenAHIReq ;Check if available
280 bsr CheckLegality ;Check if valid
282 beq BadFmt ;ERROR: Invalid
285 ;Allocate AHI's audio requester
287 OpenAHIReq: lea.l AHIReqTags1,a0
288 jlib AHI,AHI_AllocAudioRequestA
290 beq NoAHIReq ;Allocation failed
297 flib AHI,AHI_AudioRequestA
299 bne CheckCancel ;Positive gad _not_ pressed
301 ;Get values from requester and set then into the formatting template
305 cmp.l #AHI_INVALID_ID,ahiam_AudioID(a0)
306 beq CheckCancel ;None selected
308 lea.l VFPrintfArgv,a1
309 move.l ahiam_AudioID(a0),0(a1)
310 move.l ahiam_MixFreq(a0),4(a1)
312 move.l #FmtString1,d2 ;Default formatting string
314 tst.l OptDecimal ;Test for user's FmtString
316 move.l #FmtString2,d2 ;Print audio ID in decimal
318 CLIOpts2: tst.l OptLFormat
320 move.l OptLFormat,d2 ;Print audio ID in hex
322 PrintResult: move.l _stdout,d1
324 jlib Dos,VFPrintf ;Print chosen mode
329 bsr Printer ;The user string needs a CRLF pair
334 ;ShutDown routine. This cleans up EVERYTHING.
336 ;We have three ways to start it:
338 ;1. ERRShutDown - does a quick turn in Printer to print anything in a0 first
339 ;2. ERRShutDown2 - makes sure we return an error code when finished
340 ;3. ShutDown - a normal or non-fatal shutdown
343 ERRShutDown: bsr Printer
344 ERRShutDown2: move.l #RETURN_FAIL,RetCode
346 ShutDown: tst.l _AHIBase
348 move.l AHIReq1,a0 ;Allowed to be NULL
349 jlib AHI,AHI_FreeAudioRequest
351 ShutDown7000: tst.l CONFile
356 ShutDown6000: move.l RDArgs1,d1
360 ShutDown5000: tst.l _DosBase
362 move.l OrigLock,d1 ;Can be zero for root
365 ShutDown4000: tst.l DiskObject
368 jlib Icon,FreeDiskObject
370 ShutDown1500: tst.l _LocaleBase
373 jlib Locale,CloseCatalog
375 ShutDown1000: CLOSEAHI
386 ShutDown100: pull all
394 ;CheckLegality does a simple check on the user provided formatting string
395 ;so that we hopefully can't cause any Enforcer hits or any other nasty
398 ;INPUTS D2 = Pointer to formatting string
400 ;OUTPUT D2 = NULL for error or original string
402 CheckLegality: move.l d2,a0
403 clr.b d1 ;'%' counter
405 CheckLegality2: tst.b (a0)
406 beq CheckLeg_OUT ;Do until NULL
409 cmp.b #'%',(a0) ;Let user print %-sign
413 CheckLegality3: add.b #1,d1
415 bne CheckLegality2 ;OK if 2 or under
416 CheckLegality4: clr.l d2 ;Illegal
420 ;Error handling routines
423 move.l #RETURN_FAIL,d0
426 CheckCancel: move.l #RETURN_WARN,RetCode ;Set return code to WARN
427 NoRDArgs: jlib Dos,IoErr
429 beq ShutDown ;User cancelled
434 NoAHI: move.l STRNoAHIText1,a0
437 NoIcon: move.l STRNoIconText1,a0
440 NoAHIReq: move.l STRNoAHIReqText1,a0
443 BadFmt: move.l STRBadFormatText1,a0
447 ;Normal print function with Enforcer hit checks
450 beq Printer_OUT ;No string
452 beq Printer_OUT ;No content
455 jlib Dos,FPuts ;Print buffered
459 ;Reservations start here
461 libnames ;This contains macros for the library names
468 RDArgs1: dc.l 0 ;CLI arguments
469 RetCode: dc.l RETURN_OK ;Return this on exit
475 OptDecimal: dc.l 0 ;Print ID in decimal
476 OptTitle: dc.l 0 ;Window title
477 OptPositive: dc.l 0 ;Positive gad text 'OK'
478 OptNegative: dc.l 0 ;Negative gad text 'Cancel'
479 OptLFormat: dc.l 0 ;User defined formatting
480 OptPubScreen: dc.l NULLText1 ;Screen to open on
485 CONFile: dc.l 0 ;Actuall a CON window
486 _stdout: dc.l 0 ;CLI or 'CON:'
487 OrigLock: dc.l 0 ;Directory where we started
492 WBMsg: dc.l 0 ;WB message
493 DiskObject: dc.l 0 ;Icon
498 _AHIBase: dc.l 0 ;AHI device base
499 AHIReq1: dc.l 0 ;AudioID requester
501 VFPrintfArgv: dc.l 0,0 ;AHIAudioID, AHIMixFreq
506 GAICatalog: dc.l 0 ;Our translation file
507 Locale1: dc.l 0 ;Locale we're using
512 CLTemplate1: dc.b "DEC=DECIMAL/S,TITLE/K,POSITIVE/K,NEGATIVE/K,"
513 dc.b "LFORMAT/K,PUBSCREEN/K",0
514 DECIMALText1: dc.b "DECIMAL",0
515 TITLEText1: dc.b "TITLE",0
516 POSITIVEText1: dc.b "POSITIVE",0
517 NEGATIVEText1: dc.b "NEGATIVE",0
518 LFORMATText1: dc.b "LFORMAT",0
519 PUBSCREENText1: dc.b "PUBSCREEN",0
520 CONName: dc.b "CON:0/10/500/70/GetAudioID/CLOSE/AUTO/WAIT",0
521 Version: dc.b "$VER: GetAudioID "
523 dc.b " (c) Copyright Tomi Blinnikka 1996",0
524 FmtString1: dc.b "AUDIOID=0x%08lx MIXFREQ=%ld\r\n",0
525 FmtString2: dc.b "AUDIOID=%ld MIXFREQ=%ld\r\n",0
526 CRLFText1: dc.b "\r\n" ;Continues on next line!
532 EnglishText1: dc.b "english",0
533 CatalogName1: dc.b "GetAudioID.catalog",0
540 ;Tags for requester allocation
542 AHIReqTags1: dc.l AHIR_PubScreenName
547 ;Tags for showing requester
549 AHIReqTags2: dc.l AHIR_TitleText
551 dc.l AHIR_PositiveText
553 dc.l AHIR_NegativeText
555 dc.l AHIR_DoMixFreq,TRUE ;Have slider for MixFrequency
556 dc.l AHIR_InitialMixFreq,AHI_DEFMIXFREQ ;Start with this MixFreq
562 CatalogTags: dc.l OC_Language,0
563 dc.l OC_BuiltInLanguage,EnglishText1 ;We have this language built-in
569 INCDIR "LWF:AHI/GetAudioID/" ;Change to your path
570 INCLUDE "GAI_locale.i"